function select() {
    document.getElementsByClassName("info1")[0].style.display="none";
    document.getElementsByClassName("info2")[0].style.display="none";
    var b = event.target.id;
    document.getElementById(b).style.color = "#e4393c";
    document.getElementById(b).style.fontWeight = "700";
    if (b == "b1") {
        document.getElementById("b2").style.color = "#666";
        document.getElementById("b2").style.fontWeight = "400";
        document.getElementsByClassName("f3_1")[0].classList.add("sele");
        document.getElementsByClassName("f3_2")[0].classList.remove("sele");
    } else {
        document.getElementById("b1").style.color = "#666";
        document.getElementById("b1").style.fontWeight = "400";
        document.getElementsByClassName("f3_2")[0].classList.add("sele");
        document.getElementsByClassName("f3_1")[0].classList.remove("sele");
    }
}

function login() {
    var user = document.getElementById("user").value;
    var pwd = document.getElementById("pwd").value;
    document.getElementsByClassName("info1")[0].innerHTML = "用户名不存在";
    document.getElementsByClassName("info1")[0].style = "display:none";
    document.getElementsByClassName("info2")[0].innerHTML = "密码错误";
    document.getElementsByClassName("info2")[0].style = "display:none";
    if (user == "") {
        document.getElementsByClassName("info1")[0].innerHTML = "用户名不能为空";
        document.getElementsByClassName("info1")[0].style = "display:block";
        return;
    }
    if (pwd == "") {
        document.getElementsByClassName("info2")[0].innerHTML = "密码不能为空";
        document.getElementsByClassName("info2")[0].style = "display:block";
        return;
    }
    var url = "check_usr_pwd";
    var params = "username=" + encodeURI(user) + "&password=" + encodeURI(pwd);
    sendRequest(url, params, "POST", hand);
}

function createXHR() {
    //创建XMLHttpRequest对象实例
    if (window.XMLHttpRequest) {
        httpRequest = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        try {
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                httpRequest = null;
            }
        }
    }
    if (!httpRequest) {
        //获取失败
        alert("获取失败");
    }
}

function sendRequest(url, params, method, handler) {
    createXHR();
    if (!httpRequest) return false;
    httpRequest.onreadystatechange = handler;
    if (method == "GET") {
        httpRequest.open(method, url + "?" + params, true);
        httpRequest.send(null);
    }
    if (method == "POST") {
        httpRequest.open(method, url, true);
        httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        httpRequest.send(params);
    }
}